@extends('default.layouts.adminPublic')
@section('title', '定单管理')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/orderList.css')}}">
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> 订单列表
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->

    <div class="con">
        <div class="conMain">
            <div class="result_wrap">
                <div class="search">
                    <form name="Formso" id="Formso" action="{{url('admin/company_order_index')}}" method="post">

                        {{csrf_field()}}
                        <span>关键字：</span>
                        <span><input name="keyword" class="keyword" id="keyword" placeholder="企业名称或企业账号" type="text"></span>
                        <span><input name="submit" class="skeyword" value="搜索" type="submit"></span>
                    </form>
                </div>
                <div class="message"><p>目前共查找到<strong>{{$MyOrder->total()}}</strong>个合同记录！且每页显示合同记录{{$MyOrder->perPage()}}个。</p></div>
            </div>
            <div class="manage">
                @include('flash::message')
            </div>
            <div class="conInfo">
                <form name="thisForm" id="thisForm" action="" method="post">
                    {{csrf_field()}}
                    <div class="conList" id="conList">
                        <dl class="one">
                            <dt>序号</dt>
                            <dd class="ph1">套餐名称</dd>
                            <dd class="ph2">企业名称</dd>
                            <dd class="ph3">企业账号</dd>
                            <dd class="ph4">定单状态</dd>
                            <dd class="ph5">支付方式</dd>
                            <dd class="ph6">金额</dd>
                            <dd class="ph7">下单时间</dd>
                            <dd class="ph8">合同操作</dd>
                        </dl>
                        @if($MyOrder->count() > 0 )
                            @foreach($MyOrder as $k => $v)
                                <dl id="list{{ $v->id }}">
                                    <dt>{{ $k+1 }}.</dt>
                                    <dd class="ph1">{{ $v->vip_name }}</dd>
                                    <dd class="ph2">{{ $v->myOrderWithCompanyUser->company_name or '' }}</dd>
                                    <dd class="ph3">{{ $v->myOrderWithCompanyUser->username or '' }}</dd>
                                    <dd class="ph4">{{ $v->payStats }}</dd>
                                    <dd class="ph5">{{ $v->myOrderWithCollOptions->opt_name or '' }}</dd>
                                    <dd class="ph6">{{ $v->money }}</dd>
                                    <dd class="ph7">{{ $v->created_at }}</dd>
                                    <dd class="ph8">
                                        <span><a href="{{ route("admin.company_order.edit",$v->id) }}">修改订单</a></span>
                                        <span><a onclick="delOrder({{ $v->id }})">删除订单</a></span>
                                    </dd>
                                </dl>
                            @endforeach
                        @else
                            <div class="nullcon">对不起！没有合同条件的记录！</div>
                        @endif

                    </div>
                </form>
                <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                    {!! $MyOrder->links() !!}
                </div>
            </div>

            <div class="stopper" style="margin-top:10px; border-top: 1px solid #e5e5e5"></div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script>
        status = parseInt('{{ session('status') }}');
        msg = '{{ session('msg') }}';
        switch (status){
            case 0:
                layer.msg(msg,{icon: 6,width:'50px'});
                break;
            case 1:
                layer.msg(msg,{icon: 5,width:'50px'});
                break;
        }
        function delOrder(orderId){

            layer.confirm('删除定单的同时，会删除关联合同和减去企业成交合同的vip天数', {
                        btn: ['确定删除', '取消操作'] //按钮
                    },
                    function(){
                        $.post("{{url('admin/company_order')}}/" + orderId, {
                            '_method': 'delete',
                            '_token': "{{csrf_token()}}"
                        }, function (data) {
                            if (data.status == 0) {
                                $("#list"+orderId).animate({
                                    height:'hide'
                                },200);
                                layer.msg(data.msg,{icon: 6,width:'50px'});
                            } else {
                                layer.msg(data.msg,{icon: 5,width:'50px'});
                            }
                        });
                    },//success
                    function(){}//false
            );
        }
    </script>
@endsection